package TEC;

import javafx.scene.input.KeyCode;

public class KeyCodeTools {
    private KeyCode number[] = {
            KeyCode.DIGIT0,
            KeyCode.DIGIT1,
            KeyCode.DIGIT2,
            KeyCode.DIGIT3,
            KeyCode.DIGIT4,
            KeyCode.DIGIT5,
            KeyCode.DIGIT6,
            KeyCode.DIGIT7,
            KeyCode.DIGIT8,
            KeyCode.DIGIT9,
            KeyCode.NUMPAD0,
            KeyCode.NUMPAD1,
            KeyCode.NUMPAD2,
            KeyCode.NUMPAD3,
            KeyCode.NUMPAD4,
            KeyCode.NUMPAD5,
            KeyCode.NUMPAD6,
            KeyCode.NUMPAD7,
            KeyCode.NUMPAD8,
            KeyCode.NUMPAD9
    };
    private KeyCode letter[] = {
            KeyCode.A,
            KeyCode.B,
            KeyCode.C,
            KeyCode.D,
            KeyCode.E,
            KeyCode.F,
            KeyCode.G,
            KeyCode.H,
            KeyCode.I,
            KeyCode.J,
            KeyCode.K,
            KeyCode.L,
            KeyCode.M,
            KeyCode.N,
            KeyCode.O,
            KeyCode.P,
            KeyCode.Q,
            KeyCode.R,
            KeyCode.S,
            KeyCode.T,
            KeyCode.U,
            KeyCode.V,
            KeyCode.W,
            KeyCode.X,
            KeyCode.Y,
            KeyCode.Z

    };

    private boolean if_in(KeyCode keyCode, KeyCode[] keyArray) {
        for (KeyCode ones : keyArray) {
            if (keyCode == ones) {
                return true;
            }
        }
        return false;
    }

    public boolean IsNumLetter(KeyCode keyCode) {
        return if_in(keyCode, number) || if_in(keyCode, letter);
    }

    public boolean IsNum(KeyCode keyCode) {
        return if_in(keyCode, number);
    }

    public boolean IsLetter(KeyCode keyCode) {
        return if_in(keyCode, letter);
    }
}
